package com.ams.thread.lesson2;

import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * @author： 乐哥聊编程(全平台同号)
 */
@Slf4j
public class Example7 {

    public static void main(String[] args) {
        Thread sleepThread = new Thread(new SleepThread());
        sleepThread.setDaemon(true);
        Thread busyThread = new Thread(new BusyThread());
        busyThread.setDaemon(true);
        sleepThread.start();
        busyThread.start();
        ThreadUtil.sleep(5000);
        sleepThread.interrupt();
        busyThread.interrupt();
        log.info("sleepThread isInterrupted {}",sleepThread.isInterrupted());
        log.info("busyThread isInterrupted {}",busyThread.isInterrupted());
    }

    static class SleepThread implements Runnable {
        @Override
        public void run() {
           while (true){
               ThreadUtil.sleep(10000);
           }
        }
    }

    static class BusyThread implements Runnable {
        @Override
        public void run() {
           while (true){

           }
        }
    }
}
